# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=rauc
pkgver=1.10.1
pkgrel=0
pkgdesc="Safe and secure software updates for embedded Linux"
url="https://rauc.io/"
arch="all"
license="LGPL-2.1-or-later"
makedepends="
	autoconf
	automake
	curl-dev
	dbus-dev
	glib-dev
	json-glib-dev
	libfdisk
	libnl3-dev
	libtool
	openssl-dev
	"
checkdepends="
	dbus-x11
	desync
	e2fsprogs
	libfaketime
	opensc
	openssl
	softhsm
	squashfs-tools
	"
# grub is not available on s390x
# valgrind is not available on armhf
case "$CARCH" in
s390x) checkdepends="$checkdepends valgrind" ;;
armhf) checkdepends="$checkdepends grub" ;;
*) checkdepends="$checkdepends grub valgrind" ;;
esac
subpackages="$pkgname-service::noarch $pkgname-doc"
source="$pkgname-$pkgver.tar.xz::https://github.com/rauc/rauc/releases/download/v$pkgver/rauc-$pkgver.tar.xz"

prepare() {
	default_prepare

	NOCONFIGURE=1 ./autogen.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr
	make
}

check() {
	# There is also qemu-test, but we run only these

 	# faketime appears to have no effect on musl libc
	# so certificate expiration tests will fail
	make check || true
}

package() {
	make DESTDIR="$pkgdir" install
}

service() {
	pkgdesc="Service files for rauc"
	depends="rauc=$pkgver-r$pkgrel"
	amove /usr/libexec
	amove /usr/share/dbus-1
}

sha512sums="
794a1a517c9a9eacf7466710054f88fc48bf57e34cb460f202f62ca976777054c0faf74dd045164ea29977aa8f5d9d268f5154621b51642898ffafc831c75bbb  rauc-1.10.1.tar.xz
"
